package service

import (
	"choujiang/common/utils"
	"time"
	"choujiang/common/models"
	"choujiang/common/db"
	"fmt"
	"choujiang/common/consts"
)

func CreateFeedback(userId int64, feedType int64, content string, contact string) *utils.ErrorType {
	currentTime := time.Now().Unix()
	feedback := new(model.Feedback)
	feedback.Userid = userId
	feedback.Contact = contact
	feedback.Content = content
	feedback.Type = feedType
	feedback.Status = 0
	feedback.CreatedAt = currentTime
	feedback.UpdatedAt = currentTime
	_, err := db.MysqlEngine.Insert(feedback)
	if err != nil {
		fmt.Printf("CreateFeedback error is:", err)
		return consts.ErrInterval
	}
	return nil
}
